// 商品锁
package lock

import (
	"fmt"
	"strings"
)

const shopProductLockPrefix = "ying_shop_product"

type ShopProductLock struct {
	baseLock
}

func (productLock ShopProductLock) GetLockName() string {
	lockString := make([]string, 0)
	lockString = append(lockString, shopProductLockPrefix)
	lockString = append(lockString, fmt.Sprint(productLock.ItemId))
	return strings.Join(lockString, "_")
}

func GetShopProductLock(productId int) ShopProductLock {
	productLock := ShopProductLock{}
	productLock.ItemId = productId
	productLock.init(productLock.GetLockName())
	return productLock
}
